import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '设备编码',
    align:"center",
    dataIndex: 'deviceCode'
   },
   {
    title: '设备名称',
    align:"center",
    dataIndex: 'deviceName'
   },
   {
    title: '设备标识码',
    align:"center",
    dataIndex: 'deviceSn'
   },
   {
    title: '设备类型',
    align:"center",
    dataIndex: 'deviceType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'deviceType');
    },
   },
   {
    title: '设备厂商',
    align:"center",
    dataIndex: 'deviceManufacturer',
    customRender: ({ text }) => {
      return render.renderDict(text, 'deviceManufacturer');
    },
   },
   {
    title: '设备地址',
    align:"center",
    dataIndex: 'deviceIp'
   },
   {
    title: '设备端口',
    align:"center",
    dataIndex: 'devicePort'
   },
  //  {
  //   title: '所属组织编码',
  //   align:"center",
  //   dataIndex: 'ownerCode'
  //  },
   {
    title: '所属通道',
    align:"center",
    dataIndex: 'channelName'
   },
   {
    title: '在线状态',
    align:"center",
    dataIndex: 'isOnline'
   },
  //  {
  //   title: '设备离线原因',
  //   align:"center",
  //   dataIndex: 'offlineReason'
  //  },
   {
    title: '最后更新时间',
    align:"center",
    dataIndex: 'onlineUapteTime'
   },
   {
    title: '设备版本',
    align:"center",
    dataIndex: 'deviceVersion'
   },
  //  {
  //   title: '脱机记录数',
  //   align:"center",
  //   dataIndex: 'offlineRecord'
  //  },
   {
    title: '上传人员数',
    align:"center",
    dataIndex: 'personNum'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "设备编码",
      field: 'deviceCode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      //colProps: {span: 6},
 	},
   {
    label: "所属通道",
    field: 'channelId',
    component: 'Input',
    slot:'channelSlot',
    //colProps: {span: 6},
 },
  {
    label: "部门",
    field: 'depId',
    component : 'Input',
    show : false,
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '设备编码',
    field: 'deviceCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入设备编码!'},
          ];
     },
  },
  {
    label: '设备名称',
    field: 'deviceName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入设备名称!'},
          ];
     },
  },
  {
    label: '设备标识码',
    field: 'deviceSn',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
    return [
            { required: true, message: '请输入设备标识码!'},
    ];
 },
  },
  {
    label: '设备类型',
    field: 'deviceType',
    component: 'JDictSelectTag',
    defaultValue: 2,
    componentProps:{
      dictCode:"deviceType",
      stringToNumber: true
    },
    show:false
  },
  // {
  //    label: '出入类型',
  //    field: 'accessType',
  //    component: 'JDictSelectTag',
  //    componentProps:{
  //         dictCode:"accessType",
  //     }
  // },
  {
    label: '设备厂商',
    field: 'deviceManufacturer',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"deviceManufacturer"
    },
    
  },
  {
    label: '设备地址',
    field: 'deviceIp',
    component: 'Input',
  },
  {
    label: '设备端口',
    field: 'devicePort',
    component: 'InputNumber',
  },
  // {
  //   label: '所属组织编码',
  //   field: 'ownerCode',
  //   component: 'Input',
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: true, message: '请输入所属组织编码!'},
  //         ];
  //    },
  // },
  // {
  //   label: '所属通道',
  //   field: 'channelId',
  //   component: 'JDictSelectTag',
  //   componentProps:{
  //     dictCode:"ss_channel,name,id",
  //     stringToNumber: true,
  //     async:true
  //   }
  // },
  /* {
    label: '在线状态',
    field: 'isOnline',
    component: 'InputNumber',
  },
  {
    label: '设备离线原因',
    field: 'offlineReason',
    component: 'Input',
  },
  {
    label: '设备在线状态更新时间',
    field: 'onlineUapteTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  }, */
  {
    label: '设备版本',
    field: 'deviceVersion',
    component: 'Input',
  },
  /* {
    label: '脱机记录数',
    field: 'offlineRecord',
    component: 'InputNumber',
  },
  {
    label: '上传人员数',
    field: 'personNum',
    component: 'InputNumber',
  }, */
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},

];

// 高级查询数据
export const superQuerySchema = {
  deviceCode: {title: '设备编码',order: 0,view: 'text', type: 'string',},
  deviceName: {title: '设备名称',order: 1,view: 'text', type: 'string',},
  deviceSn: {title: '设备标识码',order: 2,view: 'text', type: 'string',},
  deviceType: {title: '设备类型',order: 3,view: 'number', type: 'number',},
  deviceManufacturer: {title: '设备厂商',order: 4,view: 'text', type: 'string',},
  deviceIp: {title: '设备地址',order: 5,view: 'text', type: 'string',},
  devicePort: {title: '设备端口',order: 6,view: 'number', type: 'number',},
  ownerCode: {title: '所属组织编码',order: 7,view: 'text', type: 'string',},
  isOnline: {title: '在线状态',order: 8,view: 'number', type: 'number',},
  offlineReason: {title: '设备离线原因',order: 9,view: 'text', type: 'string',},
  onlineUapteTime: {title: '设备在线状态更新时间',order: 10,view: 'datetime', type: 'string',},
  deviceVersion: {title: '设备版本',order: 11,view: 'text', type: 'string',},
  offlineRecord: {title: '脱机记录数',order: 12,view: 'number', type: 'number',},
  personNum: {title: '上传人员数',order: 13,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
